package org.gpp.proj1.test;

import java.io.FileNotFoundException;
import java.util.LinkedList;
import java.util.List;

import org.gpp.proj1.bone.Bone;
import org.gpp.proj1.bone.BoneFileParser;

import com.jme.util.LoggingSystem;

import easyaccept.EasyAccept;

public class BoneFacade {

	private List<Bone> bones;
	
	public BoneFacade(){
		// Disabling logging
		LoggingSystem.getLoggingSystem().loggerOn( false );		
		
		this.bones = new LinkedList<Bone>();
	}
	
	public void createBone(String fileName, String boneName) throws Exception{
		
		try{
			Bone bone = new Bone(boneName);
			BoneFileParser.loadKeyframes(fileName, bone);
			this.bones.add(bone);
		}catch(FileNotFoundException ex){
			
			throw new Exception("File not found!");
		}
	}
		
	public String getBoneAtribute(String atribute, int number){
		
		if( atribute.equals("actualKeyframeNumber") ){
			
			return "" + this.bones.get(number).getActualKeyframeNumber();
		}
		else if( atribute.equals("actualKeyframeLength") ){
			
			return "" + this.bones.get(number).getActualKeyframeLength();
		}
		else if( atribute.equals("actualKeyframeWidth") ){
			
			return "" + this.bones.get(number).getActualKeyframeWidth();
		}
		
		return "";
	}
	
	public void setAnimation(String name, int number){
		
		this.bones.get(number).setAnimation(name);
	}
	
	public void updateAnimation(float value, int number){
		
		this.bones.get(number).updateAnimation(value);
	}
	
	public static void main(String[] args) {
		args = new String[]{"org.gpp.proj1.test.BoneFacade", "test/bone_test.txt"};
		EasyAccept.main(args);
	}
}